import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

/**
 * @作者: xiaoxun
 * @日期: 2025/3/14 11:41
 * @描述: 服务端
 */
public class Server {
	public static void main(String[] args) throws Exception {
		//1、创建接收端对象，注册端口
		DatagramSocket socket=new DatagramSocket(8888);
		//2、创建数据包对象
		byte[] buffter=new byte[1024*64];
		DatagramPacket packet=new DatagramPacket(buffter,buffter.length);
		socket.receive(packet);
		//3、输出接收到的数据
		String msg=new String(buffter);
		System.out.println(msg);
		System.out.println("发送端地址："+packet.getAddress().getHostAddress());
		System.out.println("发送端端口："+packet.getPort());
		socket.close();//关闭管道

	}
}
